import { MessageType } from "@/types/message";
import request from "@/util/request";

// 获取私聊消息历史
export const getPrivateMessageHistory = (userId: number, friendId: number) => {
  return request({
    url: "/private/message/history",
    method: "get",
    params: { userId, friendId },
  });
};

// 标记消息为已读
export const markMessagesAsRead = (userId: number, friendId: number) => {
  return request({
    url: "/private/message/read",
    method: "post",
    params: { userId, friendId },
  });
};

// 获取群聊消息历史
export const getGroupMessageHistory = (groupId: number) => {
  return request({
    url: "/group/message/history",
    method: "get",
    params: { groupId },
  });
};

// 文件上传API
export const uploadFile = (formData: FormData, messageType: MessageType) => {
  formData.append("messageType", messageType.toString());
  return request({
    url: "/file/upload",
    method: "post",
    data: formData,
    headers: {
      "Content-Type": "multipart/form-data",
    },
  });
};
